﻿using System;
using System.Collections.Generic;
using Abp.Runtime.Session;
using pandx.Mulan.DataImExPorting.Excel;
using pandx.Mulan.Dto;
using pandx.Mulan.Flow.FlowInstances.Dto;
using pandx.Mulan.Storage;

namespace pandx.Mulan.Flow.FlowInstances.Exporting;

public class FlowInstanceListExcelExporter:NpoiExcelExporterBase,IFlowInstanceListExcelExporter
{
    private readonly IAbpSession _abpSession;
    public FlowInstanceListExcelExporter(ITempFileCacheManager tempFileCacheManager,IAbpSession abpSession) : base(tempFileCacheManager)
    {
        _abpSession = abpSession;
    }

    public FileDto ExportToExcel(List<FlowInstanceListDto> flowInstanceListDtos)
    {
        return CreateExcelPackage("流程实例_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".xlsx",
            excelPackage =>
            {
                var sheet = excelPackage.CreateSheet("流程实例");
                AddHeader(sheet,
                    "创建时间"
                );
                AddObjects(sheet,2,flowInstanceListDtos,
                        
                    _=>_.CreationTime
                   
                );
                for(var i=1;i<=flowInstanceListDtos.Count;i++)
                {
                    sheet.AutoSizeColumn(i);
                }
            });
}

}